<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript">
    $(document).ready(function () {
    
     $.getJSON("getcategory.action", function(data) {
        $.each(data, function(i, category) {
            $("#goods\\.category\\.cid").append("<option value='"+category.cid+"'>"+category.cname+"</option>");
        });
        });
        $("#submitbutton").click(function () {
            var options = {
                url: 'publishgoods.action',
                type: 'post',
                dataType: 'text',
                data: $("#publishform").serialize(),
                success: function (responsedata) {
                    if(responsedata=="8"){//发布成功
            		$('#myModal').modal('show');
            			
                    }
                    else{
                    	$("#printcontent").html("<p class='bg-danger'>添加失败</p>");
                    }
                }
            };
            $.ajax(options);
            return false;
        });
    });
  	
  	
  </script>
  <div class="container"> 
   <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;"> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 
      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button> 
       <h4 class="modal-title" id="myModalLabel">提示</h4> 
      </div> 
      <div class="modal-body" id="printcontent"><jsp:include page="upload.jsp"/></div> 
      <div class="modal-footer"> 
       <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button> 
      </div> 
     </div>
     <!-- /.modal-content --> 
    </div>
    <!-- /.modal --> 
   </div>
   <div class="row">
  	<div class="col-md-6">
  		<form  id="publishform" role="form" > 
    <div class="form-group"> 
     <label for="goods.category.cid">类别</label> 
      <select class="form-control" id="goods.category.cid" name="goods.category.cid"></select>
    </div> 
    <input type="text" id="goods.user.uid" name="goods.user.uid" style="display:none;" value='<s:property value="#session.user.uid"/>' /> 
	<div class="form-group"> 
     <label for="goods.gname">名称</label> 
      <input type="text" class="form-control" id="goods.gname" name="goods.gname" placeholder="名称" /> 
    </div> 
    <div class="form-group"> 
     <label for="goods.gprice" >价格</label> 
      <input type="text" class="form-control" id="goods.gprice" name="goods.gprice" placeholder="价格" /> 
    </div> 
	<div class="form-group"> 
     <label for="goods.gnumber" >数量</label> 
      <input type="text" class="form-control" id="goods.gnumber" name="goods.gnumber" placeholder="数量" /> 
    </div> 
	
    <div class="form-group"> 
     <label for="goods.gaddress" >地址</label> 
      <input type="text" class="form-control" id="goods.gaddress" name="goods.gaddress" placeholder="地址" /> 
    </div> 
	<div class="form-group"> 
     <label for="goods.ginfo" >商品简短说明</label> 
      <input type="text" class="form-control" id="goods.ginfo" name="goods.ginfo" placeholder="商品简短说明" /> 
    </div> 
    <input type="text" id="goods.gshow" name="goods.gshow" style="display:none;"  value="1" /> 
    <input type="text" id="goods.gcount" name="goods.gcount" style="display:none;" value="0" /> 
    <div class="form-group"> 
     <div class="col-sm-offset-2 col-sm-10"> 
      <button type="submit" id="submitbutton" class="btn btn-default">提交</button> 
     </div> 
    </div> 
   </form> 
	</div>
  	<div class="col-md-6"></div>
	</div> 
   
  </div>
